home *** CD-ROM | disk | FTP | other *** search
- Path: news.rrz.uni-hamburg.de!rzdspc1!simmons
- From: simmons@rzdspc1.informatik.uni-hamburg.de (Geoffrey Simmons)
- Newsgroups: comp.lang.c,gnu.gcc.help
- Subject: Re: Casting unsigned short as unsigned int -> Bus error
- Date: 29 Jan 96 16:54:17 GMT
- Organization: University of Hamburg -- Germany
- Message-ID: <simmons.822934457@rzdspc1>
- References: <simmons.820857453@rzdspc1> <820879186snz@genesis.demon.co.uk> <4e8v6t$bd2@crl.crl.com> <822701517snz@genesis.demon.co.uk>
- NNTP-Posting-Host: rzdspc1.informatik.uni-hamburg.de
-
- I was amazed to look back into comp.lang.c to find that this thread, which
- I started, is still alive.
-
- It turned out that the problem I was having was related to alignment, but
- had nothing to do with casting unsigned int as unsigned short, so I changed
- the Subject: line and went from there.
-
- For the record: I was reading data from a database into a struct using
- Unix NDBM. The NDBM routines return a pointer, but (as I learned) the fields
- in the struct that it points to are not guaranteed to be aligned properly.
-
- The solution was to copy the data into a properly-declared struct using
- memcpy().
-
- Thanks to all who helped,
- Geoff
- --
- Geoffrey Simmons | simmons@informatik.uni-hamburg.de | "Insert wise
- University of Hamburg | Phone: (++49 40) 54715-381 | and witty
- Vogt-Koelln-Str. 30 | Fax: (++49 40) 54715-385 | quotation
- D-22527 Hamburg, Germany | | here."
-